package starter.kit.rx.app.feature.film;

import android.os.Bundle;

import rx.Observable;
import starter.kit.feature.rx.RxNetworkPresenter;
import starter.kit.rx.app.model.bean.filmdetail.FilmDetail;
import starter.kit.rx.app.network.ApiService;
import starter.kit.rx.app.network.service.DoubanService;
import starter.kit.util.RxUtils;

/**
 * ============================================================
 * 版权： xx 版权所有（c）2016
 * <p>
 * 作者：Loofer
 * 版本：1.0
 * 创建日期 ：2016/10/26 19:12.
 * 描述：
 * <p>
 * 注:如果您修改了本类请填写以下内容作为记录，如非本人操作劳烦通知，谢谢！！！
 * Modified Date Modify Content:
 * <p>
 * ==========================================================
 */
public class FilmDetailPresenter extends RxNetworkPresenter<FilmDetail,FilmDetailActivity> {


    private DoubanService mDoubanService;
    private String mId;


    @Override
    protected void onCreate(Bundle savedState) {
        super.onCreate(savedState);
        mDoubanService = ApiService.creatDoubanService();
    }


    @Override
    public Observable<FilmDetail> request() {
        return mDoubanService.getFilmDetail(mId);
    }

    void requestItem(String id) {
        this.mId = id;
        start();
    }


    @Override
    public void showHud() {
        RxUtils.showHud(getView(), "Loading...", this::stop);
    }
}
